package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.GongzuoRzDetailModel;
import com.epoint.mobileoa.personalized.epointcompany.model.ProjectInfoModel;

/**
 * @author liyc
 * @time 2012-4-5 下午2:22:56
 * @annotation 获取日志填写后台信息，任务信息
 */
public class GetRZTXInfo extends Task {

	public GetRZTXInfo(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String userguid = getCon().fp.getUserguid();
		String rzdate = getParam().get("rzdate").toString().substring(0, 10);
		String gzrzguid = getParam().get("rzguid").toString();
		String seamurl = getCon().fp.generateUrl("Epoint_GetRZINFO",userguid,rzdate,gzrzguid);
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(),bs);
	}
	
	public static List<GongzuoRzDetailModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<GongzuoRzDetailModel> plist = new ArrayList<GongzuoRzDetailModel>();
		for (int i = 0; i < focs.size(); i++) {
			GongzuoRzDetailModel mt = new GongzuoRzDetailModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("RowGuid") != null)
				mt.RowGuid = foc.elementText("RowGuid");
			if (foc.element("ProjectName") != null)
				mt.ProjectName = foc.elementText("ProjectName");
			if (foc.element("MissionName") != null)
				mt.MissionName = foc.elementText("MissionName");
			if (foc.element("MissionGuid") != null)
				mt.MissionGuid = foc.elementText("MissionGuid");
			if (foc.element("GongZuoNR") != null)
				mt.GongZuoNR = foc.elementText("GongZuoNR");
			if (foc.element("GongZuoSJ") != null)
				mt.GongZuoSJ = foc.elementText("GongZuoSJ");
			if (foc.element("ExtraWorkSJ") != null)
				mt.ExtraWorkSJ = foc.elementText("ExtraWorkSJ");
			if (foc.element("StandardWorkTime") != null)
				mt.StandardWorkTime = foc.elementText("StandardWorkTime");
			if (foc.element("ExtreaStandardSJ") != null)
				mt.ExtreaStandardSJ = foc.elementText("ExtreaStandardSJ");
			if (foc.element("CheckWorkSJ") != null)
				mt.CheckWorkSJ = foc.elementText("CheckWorkSJ");
			if (foc.element("CheckStaWorkSJ") != null)
				mt.CheckStaWorkSJ = foc.elementText("CheckStaWorkSJ");
			if (foc.element("CompletePercent") != null)
				mt.CompletePercent = foc.elementText("CompletePercent");
			if (foc.element("ContentType") != null)
				mt.ContentType = foc.elementText("ContentType");
			if (foc.element("ContentTypeName") != null)
				mt.ContentTypeName = foc.elementText("ContentTypeName");
			plist.add(mt);
		}
		return plist;
	}

}
